import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import commonjs from '@rollup/plugin-commonjs';//引入commojs
import config from './src/config';
// 引入require
import requireTransform from 'vite-plugin-require-transform';

// https://vitejs.dev/config/
export default defineConfig({
  base: config.VITE_APP_BASE_URL,
  plugins: [
    commonjs() as any,
    vue(),
    VueSetupExtend(),
    requireTransform({
      fileRegex: /.js$|.vue$|.png$|.ts$|.jpg$/
    }) //配置require
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    host: '0.0.0.0'
  },
})
